package cn.stylefeng.guns.sys.modular.notice.service.impl;

import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.guns.core.context.login.LoginContextHolder;
import cn.stylefeng.guns.sys.modular.notice.entity.SysNotice;
import cn.stylefeng.guns.sys.modular.notice.entity.SysNoticeUser;
import cn.stylefeng.guns.sys.modular.notice.mapper.SysNoticeMapper;
import cn.stylefeng.guns.sys.modular.notice.mapper.SysNoticeUserMapper;
import cn.stylefeng.guns.sys.modular.notice.service.SysNoticeUserService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 用户系统公告记录表 服务实现类
 *
 * @author 李文龙
 * @date 2021/09/22 15:24
 */
@Transactional(rollbackFor = Exception.class)
@Service
public class SysNoticeUserServiceImpl extends ServiceImpl<SysNoticeUserMapper, SysNoticeUser> implements SysNoticeUserService {
    @Override
    public void add(Long noticeId, Long userId) {

            SysNoticeUser sysNoticeUser = new SysNoticeUser();
            sysNoticeUser.setNoticeId(noticeId);
            sysNoticeUser.setUserId(userId);
            sysNoticeUser.setCreateTime(new Date());
            sysNoticeUser.setUpdateTime(new Date());
            this.save(sysNoticeUser);

    }


    @Override
    public List<SysNoticeUser> getSysNoticeUserListByNoticeId(Long noticeId) {
        LambdaQueryWrapper<SysNoticeUser> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SysNoticeUser::getNoticeId, noticeId);
        return this.list(queryWrapper);
    }
}

